package top.caoayu.codewars;

import java.util.Arrays;
import java.util.stream.IntStream;

public class Kata {

    public static int[] countBy(int x, int n) {
        // Your code here
        int[] result = new int[n];
        for (int i = 0; i < n; i++) {
            result[i] = x * (i + 1);
        }
        return result;
    }

    public static char getGrade(int s1, int s2, int s3) {
        int mean = (s1 + s2 + s3) / 3;
        if (mean >= 90) return 'A';
        if (mean >= 80) return 'B';
        if (mean >= 70) return 'C';
        if (mean >= 60) return 'D';
        return 'F';
    }

    public static int areaOrPerimeter(int l, int w) {
        // code away...
        if (l == w) {
            return l * w;
        }
        return 2 * (l + w);
    }

    public static int quarterOf(int month) {
        // Your code here
        if (3 >= month && month >= 1) return 1;
        if (6 >= month && month > 3) return 2;
        if (9 >= month && month > 6) return 3;
        return 4;
    }

    public int min(int[] list) {
        return Arrays.stream(list).min().orElse(0);
    }

    public int max(int[] list) {
        return Arrays.stream(list).max().orElse(0);
    }


}